package cn.tedu.baking.controller;

import cn.tedu.baking.commons.response.JsonResult;
import cn.tedu.baking.pojo.vo.BannerAdminVO;
import cn.tedu.baking.service.IBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/banners/")
public class BannerController {
    @Autowired
    IBannerService service;
    @GetMapping("")
    public JsonResult listForIndex(){

        return JsonResult.ok(service.listForIndex());
    }
    @GetMapping("admin")
    public JsonResult adminList(){
        List<BannerAdminVO> list = service.listForAdmin();
        return JsonResult.ok(list);
    }
    @PostMapping("{id}/delete")
    public JsonResult delete(@PathVariable Long id){
        service.deleteById(id);
        return JsonResult.ok();
    }

}
